package com.ctvit.sjk.knowledge.app.controller;

import com.ctvit.sjk.knowledge.app.pojo.domain.TabAppPublicAccessClient;
import com.ctvit.sjk.knowledge.app.service.ITabAppPublicAccessClientService;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.enums.BusinessType;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * 应用公共访问客户端Controller
 *
 * @author heyingcheng
 * @date 2025/3/22
 */
@RestController
@RequestMapping("knowledge/app/public/access/client")
public class TabAppPublicAccessClientController extends BaseController {

    private final ITabAppPublicAccessClientService tabAppPublicAccessClientService;

    public TabAppPublicAccessClientController(ITabAppPublicAccessClientService tabAppPublicAccessClientService) {
        this.tabAppPublicAccessClientService = tabAppPublicAccessClientService;
    }

    /**
     * 查询应用公共访问客户端列表
     */
    @PostMapping("list")
    public TableDataInfo list() {
        return getDataTable(tabAppPublicAccessClientService.list());
    }

    /**
     * 获取应用公共访问客户端详细信息
     */
    @PostMapping(value = "get")
    public AjaxResult get(@RequestParam String id) {
        return success(tabAppPublicAccessClientService.getById(id));
    }

    /**
     * 新增应用公共访问客户端
     */
    @Log(title = "应用公共访问客户端", businessType = BusinessType.INSERT)
    @PostMapping(value = "add")
    public AjaxResult add(@RequestBody TabAppPublicAccessClient entity) {
        return toAjax(tabAppPublicAccessClientService.save(entity));
    }

    /**
     * 修改应用公共访问客户端
     */
    @Log(title = "应用公共访问客户端", businessType = BusinessType.UPDATE)
    @PostMapping(value = "edit")
    public AjaxResult edit(@RequestBody TabAppPublicAccessClient entity) {
        return toAjax(tabAppPublicAccessClientService.updateById(entity));
    }

    /**
     * 删除应用公共访问客户端
     */
    @Log(title = "应用公共访问客户端", businessType = BusinessType.DELETE)
    @PostMapping("remove")
    public AjaxResult remove(@RequestBody List<String> ids) {
        return toAjax(tabAppPublicAccessClientService.removeByIds(ids));
    }

}
